<?php

class Cloud {


public function nuevaNube(){
    
    $seccion = new Seccion();
    $secciones = $seccion->getSeccionMenu();
    $xmlstring ="<tags>";

    foreach ($secciones as $seccion){

        $xmlstring .="<a href='seccion/show?id=".$seccion->getId()."' hicolor='0x".$this->random_color()."' color='0x".$this->random_color()."' style='font-size:".$this->random_num()."' >".$seccion->getNombre()."</a>\n";

    }


    $categoria = new Categoria();
    $categorias = $categoria->getCategoria();
    
    foreach ($categorias as $categoria){
       
        $xmlstring .="<a href='categoria/show?id=".$categoria->getId()."' hicolor='0x".$this->random_color()."' color='0x".$this->random_color()."' style='font-size:".$this->random_num()."' >".$categoria->getNombre()."</a>\n";

    }
    
    $xmlstring .= "</tags>";
    $path=sfConfig::get('sf_upload_dir')."/componente/cloud_data.xml";
    $Open = fopen ($path,"w+");


    if ($Open) {
        fwrite ($Open,"$xmlstring");

    }

}

function random_num(){
   $num =  mt_rand(8,14);
   return $num;
}


function random_color(){
    mt_srand((double)microtime()*1000000);
    $c = '';
    while(strlen($c)<6){
        $c .= sprintf("%02X", mt_rand(0, 255));
    }
    return $c;
}

public function agregarNube(){

    $xmlstring =<<<HTML
<tags>
<a href="http://diarioregion.com.ve/site/index.phpdel" hicolor="0xa06764" color="0x5312c5" style="font-size:11">del</a>
<a href="http://diarioregion.com.ve/site/index.phpsucre" hicolor="0xa72d82" color="0xcbbfd7" style="font-size:13">sucre</a>
<a href="http://diarioregion.com.ve/site/index.phpopinion" hicolor="0x65ce84" color="0x89ac16" style="font-size:9">opinion</a>
<a href="http://diarioregion.com.ve/site/index.phpmunicipios" hicolor="0x2f777b" color="0x57a6ec" style="font-size:7">municipios</a>
<a href="http://diarioregion.com.ve/site/index.phpnacionales" hicolor="0xae154d" color="0xa6ba06" style="font-size:13">nacionales</a>
<a href="http://diarioregion.com.ve/site/index.phpinternacionales" hicolor="0x4b159e" color="0x640855" style="font-size:13">internacionales</a>
</tags>
HTML;

$path=sfConfig::get('sf_upload_dir')."/componente/cloud_data.xml";

$Open = fopen ($path,"a+");



if ($Open) {

    fwrite ($Open,"$xmlstring");

    }
}


}
?>
